package com.android.common;

import java.util.LinkedList;

import android.app.Activity;
import android.content.Context;

import com.android.common.util.StringUtil;

public class ActivityManager {

	private Context mContext;

	private static ActivityManager mInstance;

	private static final LinkedList<Activity> activityList = new LinkedList<Activity>();

	public static ActivityManager getInstance() {
		if (mInstance == null) {
			mInstance = new ActivityManager();
		}
		return mInstance;
	}

	public Context getCurrentContext() {
		return mContext;
	}

	public String getCurrentContextName() {
		return StringUtil.objectToString(mContext);
	}

	public void setCurrentContext(Context context) {
		mContext = context;
	}

	public void onCreateActivity(Activity a) {
		activityList.add(a);
	}

	public void onDestoryActivity(Activity a) {
		activityList.remove(a);
	}

	public void destory() {
		for (Activity a : activityList) {
			a.finish();
		}
	}
}
